package com.xunyi.learndemo.config;

import io.netty.util.HashedWheelTimer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class TimerConfig {

    @Bean(destroyMethod = "stop")
    public HashedWheelTimer hashedWheelTimer() {
        // 创建HashedWheelTimer，设置tick时长为100ms，时间轮有512个槽，最长延时为512 * 100ms
        return new HashedWheelTimer(100, TimeUnit.MILLISECONDS, 512);
    }
}

